package com.wind.employee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wind.common.annotation.Log;
import com.wind.common.core.controller.BaseController;
import com.wind.common.core.domain.AjaxResult;
import com.wind.common.enums.BusinessType;
import com.wind.employee.domain.ChenEmployee;
import com.wind.employee.service.IChenEmployeeService;
import com.wind.common.utils.poi.ExcelUtil;
import com.wind.common.core.page.TableDataInfo;

/**
 * 职工表自动生成Controller
 * 
 * @author 陈修昊
 * @date 2023-05-16
 */
@RestController
@RequestMapping("/devlop/employee")
public class ChenEmployeeController extends BaseController
{
    @Autowired
    private IChenEmployeeService chenEmployeeService;

    /**
     * 查询职工表自动生成列表
     */
    @PreAuthorize("@ss.hasPermi('devlop:employee:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChenEmployee chenEmployee)
    {
        startPage();
        List<ChenEmployee> list = chenEmployeeService.selectChenEmployeeList(chenEmployee);
        return getDataTable(list);
    }

    /**
     * 导出职工表自动生成列表
     */
    @PreAuthorize("@ss.hasPermi('devlop:employee:export')")
    @Log(title = "职工表自动生成", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChenEmployee chenEmployee)
    {
        List<ChenEmployee> list = chenEmployeeService.selectChenEmployeeList(chenEmployee);
        ExcelUtil<ChenEmployee> util = new ExcelUtil<ChenEmployee>(ChenEmployee.class);
        util.exportExcel(response, list, "职工表自动生成数据");
    }

    /**
     * 获取职工表自动生成详细信息
     */
    @PreAuthorize("@ss.hasPermi('devlop:employee:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(chenEmployeeService.selectChenEmployeeById(id));
    }

    /**
     * 新增职工表自动生成
     */
    @PreAuthorize("@ss.hasPermi('devlop:employee:add')")
    @Log(title = "职工表自动生成", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChenEmployee chenEmployee)
    {
        return toAjax(chenEmployeeService.insertChenEmployee(chenEmployee));
    }

    /**
     * 修改职工表自动生成
     */
    @PreAuthorize("@ss.hasPermi('devlop:employee:edit')")
    @Log(title = "职工表自动生成", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChenEmployee chenEmployee)
    {
        return toAjax(chenEmployeeService.updateChenEmployee(chenEmployee));
    }

    /**
     * 删除职工表自动生成
     */
    @PreAuthorize("@ss.hasPermi('devlop:employee:remove')")
    @Log(title = "职工表自动生成", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(chenEmployeeService.deleteChenEmployeeByIds(ids));
    }
}
